var _ = require('underscore')
var Category =require('../models/category')//../上层目录  ./当前目录

//list page
exports.categorylist = function(req, res){
	Category.fetch(function(err, categories){//这个fetch 是在shemale里面置自定的函数
		if (err) {
			console.log(err)
		}
		res.render('categorylist',{
		title:'imooc 分类列表页',
		categories:categories
		})
	})
	
}

//admin page
exports.new=function(req, res){
	res.render('category_admin',{
		title:'imooc 后台分类录入页',
		category:{}
	})
}


//admin post movie
exports.save = function(req, res){
	var _category = req.body.category
	var	category = new Category(_category)

	category.save(function(err,category){
		if (err) {
			comsole.log(err)
		}

		res.redirect('/admin/category/list')
	})
}

